Skip to content

ci: harden workflows - #287

Merged
DeepDiver1975 merged 2 commits into
mainfrom
ci/review-harden-workflows
Sep 10, 2026
Merged

DeepDiver1975 merged 2 commits into
mainfrom
ci/review-harden-workflows

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Problem

  • ci.yml had no permissions: block, so the job that builds and tests untrusted pull-request code ran with whatever the org default grants.
  • claude.yml triggered on any comment, review or issue containing @claude, from any GitHub account, with contents: write and unattended dotnet restore/build/test. A stranger could start a write-token job that runs MSBuild targets from a pull request tree.
  • The Makefile's format-check never ran in CI, so dotnet format drift landed on main unchallenged.
  • Dependabot's NuGet entry only covered the repository root, not the two nested Directory.Packages.props files (Android head, acceptance tests).

All third-party actions were already SHA-pinned; those pins are unchanged.

Fix

  • ci.yml: workflow-level permissions: contents: read; a format-check step.
  • claude.yml: every trigger gated on author_association in OWNER/MEMBER/COLLABORATOR; permissions reduced to what the action needs (see the inline comment for contents).
  • dependabot.yml: NuGet entries for the two nested package directories.
  • CHANGELOG entry.

Found during a security review of main; part of a series of review follow-up PRs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PXhXSh2pae9WnaACYUUe3V

DeepDiver1975 and others added 2 commits September 10, 2026 11:23
RemoteClientTests.cs had a whitespace violation that dotnet format
whitespace/style would flag under --verify-no-changes. Fix it so the
new CI format-check step (added in the following commit) is green on
main.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXhXSh2pae9WnaACYUUe3V
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
- ci.yml: add a workflow-level `permissions: contents: read` block. It
  builds and tests untrusted pull_request code, so the token should be
  read-only regardless of org/repo defaults. Add a "Format check" step
  (dotnet format whitespace/style --verify-no-changes, matching the
  Makefile's format-check target) between Restore and Build so
  formatting drift can no longer land on main.
- claude.yml: gate every trigger event on the actor's author
  association (OWNER/MEMBER/COLLABORATOR), in addition to the existing
  @claude substring checks, so an arbitrary GitHub account can no
  longer make this write-token job run MSBuild from a PR tree. Keep
  `contents: write`: anthropics/claude-code-action's GitHub App lists
  "Contents (Read & Write): For reading repository files and creating
  branches" as a currently-used permission, and the action's default
  flow is to commit a fix branch and link a PR-creation URL, which
  needs write access.
- dependabot.yml: add nuget entries for
  src/LageBuch.App.Android and tests/LageBuch.Acceptance.Tests, which
  each declare their own Directory.Packages.props and were not
  previously covered by the root entry.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXhXSh2pae9WnaACYUUe3V
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@DeepDiver1975
DeepDiver1975 merged commit 65356fa into main Sep 10, 2026
2 checks passed
@DeepDiver1975
DeepDiver1975 deleted the ci/review-harden-workflows branch September 10, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant